<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input  type="text"  name="username"  value="tom"  class="orange" />
		<a href="http://www.baidu.com"  addr="beijing" target="_blank">百度</a>
		<br />
		<button onclick="f1()">测试</button>
		
		<script type="text/javascript">
			window.onload = function() {
				var input = document.getElementsByTagName('input')[0];
				console.log(input.type);
				console.log(input.name);
				console.log(input.value);
				console.log(input.className);
				
				var baidu = document.getElementsByTagName('a')[0];
				console.log(baidu.href);
				console.log(baidu.addr);// undefined
				
				console.log(baidu.getAttribute('href'));
				console.log(baidu.getAttribute('addr'));
			}
			
			function f1() {
				var input = document.getElementsByTagName('input')[0];
				input.value = 'hello tom';
				
				var baidu = document.getElementsByTagName('a')[0];
				baidu.setAttribute('href', 'http://jd.com');
				baidu.setAttribute('addr', '山东');
			}
		</script>
	</body>
</html>
